using System;
using System.CodeDom.Compiler;
using System.ComponentModel;
using System.Diagnostics;
using System.Net;
using System.Runtime.CompilerServices;
using System.ServiceModel;
using System.ServiceModel.Channels;
using System.Threading;
namespace Microsoft.Phone.Controls.Maps.ConfigService
{
	[GeneratedCode("System.ServiceModel", "4.0.0.0"), DebuggerStepThrough]
	internal class MapControlConfigurationServiceClient : ClientBase<IMapControlConfigurationService>, IMapControlConfigurationService
	{
		private class MapControlConfigurationServiceClientChannel : ClientBase<IMapControlConfigurationService>.ChannelBase<IMapControlConfigurationService>, IMapControlConfigurationService
		{
			public MapControlConfigurationServiceClientChannel(ClientBase<IMapControlConfigurationService> client) : base(client)
			{
			}
			public IAsyncResult BeginGetConfiguration(MapControlConfigurationRequest request, AsyncCallback callback, object asyncState)
			{
				return base.BeginInvoke("GetConfiguration", new object[]
				{
					request
				}, callback, asyncState);
			}
			public MapControlConfigurationResponse EndGetConfiguration(IAsyncResult result)
			{
				object[] array = new object[0];
				return (MapControlConfigurationResponse)base.EndInvoke("GetConfiguration", array, result);
			}
		}
		private ClientBase<IMapControlConfigurationService>.BeginOperationDelegate onBeginGetConfigurationDelegate;
		private ClientBase<IMapControlConfigurationService>.EndOperationDelegate onEndGetConfigurationDelegate;
		private SendOrPostCallback onGetConfigurationCompletedDelegate;
		private ClientBase<IMapControlConfigurationService>.BeginOperationDelegate onBeginOpenDelegate;
		private ClientBase<IMapControlConfigurationService>.EndOperationDelegate onEndOpenDelegate;
		private SendOrPostCallback onOpenCompletedDelegate;
		private ClientBase<IMapControlConfigurationService>.BeginOperationDelegate onBeginCloseDelegate;
		private ClientBase<IMapControlConfigurationService>.EndOperationDelegate onEndCloseDelegate;
		private SendOrPostCallback onCloseCompletedDelegate;
		public event EventHandler<GetConfigurationCompletedEventArgs> GetConfigurationCompleted
		{
			[MethodImpl(32)]
			add
			{
				this.GetConfigurationCompleted = (EventHandler<GetConfigurationCompletedEventArgs>)Delegate.Combine(this.GetConfigurationCompleted, value);
			}
			[MethodImpl(32)]
			remove
			{
				this.GetConfigurationCompleted = (EventHandler<GetConfigurationCompletedEventArgs>)Delegate.Remove(this.GetConfigurationCompleted, value);
			}
		}
		public event EventHandler<AsyncCompletedEventArgs> OpenCompleted
		{
			[MethodImpl(32)]
			add
			{
				this.OpenCompleted = (EventHandler<AsyncCompletedEventArgs>)Delegate.Combine(this.OpenCompleted, value);
			}
			[MethodImpl(32)]
			remove
			{
				this.OpenCompleted = (EventHandler<AsyncCompletedEventArgs>)Delegate.Remove(this.OpenCompleted, value);
			}
		}
		public event EventHandler<AsyncCompletedEventArgs> CloseCompleted
		{
			[MethodImpl(32)]
			add
			{
				this.CloseCompleted = (EventHandler<AsyncCompletedEventArgs>)Delegate.Combine(this.CloseCompleted, value);
			}
			[MethodImpl(32)]
			remove
			{
				this.CloseCompleted = (EventHandler<AsyncCompletedEventArgs>)Delegate.Remove(this.CloseCompleted, value);
			}
		}
		public CookieContainer CookieContainer
		{
			get
			{
				IHttpCookieContainerManager property = base.get_InnerChannel().GetProperty<IHttpCookieContainerManager>();
				if (property != null)
				{
					return property.get_CookieContainer();
				}
				return null;
			}
			set
			{
				IHttpCookieContainerManager property = base.get_InnerChannel().GetProperty<IHttpCookieContainerManager>();
				if (property == null)
				{
					throw new InvalidOperationException("Unable to set the CookieContainer. Please make sure the binding contains an HttpCookieContainerBindingElement.");
				}
				property.set_CookieContainer(value);
			}
		}
		public MapControlConfigurationServiceClient()
		{
		}
		public MapControlConfigurationServiceClient(string endpointConfigurationName) : base(endpointConfigurationName)
		{
		}
		public MapControlConfigurationServiceClient(string endpointConfigurationName, string remoteAddress) : base(endpointConfigurationName, remoteAddress)
		{
		}
		public MapControlConfigurationServiceClient(string endpointConfigurationName, EndpointAddress remoteAddress) : base(endpointConfigurationName, remoteAddress)
		{
		}
		public MapControlConfigurationServiceClient(Binding binding, EndpointAddress remoteAddress) : base(binding, remoteAddress)
		{
		}
		[EditorBrowsable]
		IAsyncResult IMapControlConfigurationService.BeginGetConfiguration(MapControlConfigurationRequest request, AsyncCallback callback, object asyncState)
		{
			return base.get_Channel().BeginGetConfiguration(request, callback, asyncState);
		}
		[EditorBrowsable]
		MapControlConfigurationResponse IMapControlConfigurationService.EndGetConfiguration(IAsyncResult result)
		{
			return base.get_Channel().EndGetConfiguration(result);
		}
		private IAsyncResult OnBeginGetConfiguration(object[] inValues, AsyncCallback callback, object asyncState)
		{
			MapControlConfigurationRequest request = (MapControlConfigurationRequest)inValues[0];
			return ((IMapControlConfigurationService)this).BeginGetConfiguration(request, callback, asyncState);
		}
		private object[] OnEndGetConfiguration(IAsyncResult result)
		{
			MapControlConfigurationResponse mapControlConfigurationResponse = ((IMapControlConfigurationService)this).EndGetConfiguration(result);
			return new object[]
			{
				mapControlConfigurationResponse
			};
		}
		private void OnGetConfigurationCompleted(object state)
		{
			if (this.GetConfigurationCompleted != null)
			{
				ClientBase<IMapControlConfigurationService>.InvokeAsyncCompletedEventArgs invokeAsyncCompletedEventArgs = (ClientBase<IMapControlConfigurationService>.InvokeAsyncCompletedEventArgs)state;
				this.GetConfigurationCompleted.Invoke(this, new GetConfigurationCompletedEventArgs(invokeAsyncCompletedEventArgs.get_Results(), invokeAsyncCompletedEventArgs.get_Error(), invokeAsyncCompletedEventArgs.get_Cancelled(), invokeAsyncCompletedEventArgs.get_UserState()));
			}
		}
		public void GetConfigurationAsync(MapControlConfigurationRequest request)
		{
			this.GetConfigurationAsync(request, null);
		}
		public void GetConfigurationAsync(MapControlConfigurationRequest request, object userState)
		{
			if (this.onBeginGetConfigurationDelegate == null)
			{
				this.onBeginGetConfigurationDelegate = new ClientBase<IMapControlConfigurationService>.BeginOperationDelegate(this.OnBeginGetConfiguration);
			}
			if (this.onEndGetConfigurationDelegate == null)
			{
				this.onEndGetConfigurationDelegate = new ClientBase<IMapControlConfigurationService>.EndOperationDelegate(this.OnEndGetConfiguration);
			}
			if (this.onGetConfigurationCompletedDelegate == null)
			{
				this.onGetConfigurationCompletedDelegate = new SendOrPostCallback(this.OnGetConfigurationCompleted);
			}
			base.InvokeAsync(this.onBeginGetConfigurationDelegate, new object[]
			{
				request
			}, this.onEndGetConfigurationDelegate, this.onGetConfigurationCompletedDelegate, userState);
		}
		private IAsyncResult OnBeginOpen(object[] inValues, AsyncCallback callback, object asyncState)
		{
			return this.BeginOpen(callback, asyncState);
		}
		private object[] OnEndOpen(IAsyncResult result)
		{
			this.EndOpen(result);
			return null;
		}
		private void OnOpenCompleted(object state)
		{
			if (this.OpenCompleted != null)
			{
				ClientBase<IMapControlConfigurationService>.InvokeAsyncCompletedEventArgs invokeAsyncCompletedEventArgs = (ClientBase<IMapControlConfigurationService>.InvokeAsyncCompletedEventArgs)state;
				this.OpenCompleted.Invoke(this, new AsyncCompletedEventArgs(invokeAsyncCompletedEventArgs.get_Error(), invokeAsyncCompletedEventArgs.get_Cancelled(), invokeAsyncCompletedEventArgs.get_UserState()));
			}
		}
		public void OpenAsync()
		{
			this.OpenAsync(null);
		}
		public void OpenAsync(object userState)
		{
			if (this.onBeginOpenDelegate == null)
			{
				this.onBeginOpenDelegate = new ClientBase<IMapControlConfigurationService>.BeginOperationDelegate(this.OnBeginOpen);
			}
			if (this.onEndOpenDelegate == null)
			{
				this.onEndOpenDelegate = new ClientBase<IMapControlConfigurationService>.EndOperationDelegate(this.OnEndOpen);
			}
			if (this.onOpenCompletedDelegate == null)
			{
				this.onOpenCompletedDelegate = new SendOrPostCallback(this.OnOpenCompleted);
			}
			base.InvokeAsync(this.onBeginOpenDelegate, null, this.onEndOpenDelegate, this.onOpenCompletedDelegate, userState);
		}
		private IAsyncResult OnBeginClose(object[] inValues, AsyncCallback callback, object asyncState)
		{
			return this.BeginClose(callback, asyncState);
		}
		private object[] OnEndClose(IAsyncResult result)
		{
			this.EndClose(result);
			return null;
		}
		private void OnCloseCompleted(object state)
		{
			if (this.CloseCompleted != null)
			{
				ClientBase<IMapControlConfigurationService>.InvokeAsyncCompletedEventArgs invokeAsyncCompletedEventArgs = (ClientBase<IMapControlConfigurationService>.InvokeAsyncCompletedEventArgs)state;
				this.CloseCompleted.Invoke(this, new AsyncCompletedEventArgs(invokeAsyncCompletedEventArgs.get_Error(), invokeAsyncCompletedEventArgs.get_Cancelled(), invokeAsyncCompletedEventArgs.get_UserState()));
			}
		}
		public void CloseAsync()
		{
			this.CloseAsync(null);
		}
		public void CloseAsync(object userState)
		{
			if (this.onBeginCloseDelegate == null)
			{
				this.onBeginCloseDelegate = new ClientBase<IMapControlConfigurationService>.BeginOperationDelegate(this.OnBeginClose);
			}
			if (this.onEndCloseDelegate == null)
			{
				this.onEndCloseDelegate = new ClientBase<IMapControlConfigurationService>.EndOperationDelegate(this.OnEndClose);
			}
			if (this.onCloseCompletedDelegate == null)
			{
				this.onCloseCompletedDelegate = new SendOrPostCallback(this.OnCloseCompleted);
			}
			base.InvokeAsync(this.onBeginCloseDelegate, null, this.onEndCloseDelegate, this.onCloseCompletedDelegate, userState);
		}
		protected override IMapControlConfigurationService CreateChannel()
		{
			return new MapControlConfigurationServiceClient.MapControlConfigurationServiceClientChannel(this);
		}
	}
}
